package com.intelligence.common.system;

import com.intelligence.entity.pojo.Device;

import java.util.List;

/**
 * @Author : RulerWood
 * @Data : 2024/6/6 - 15:22
 */
public class GeneralInterExchangeUtils {
    /**
     * 生成采集的值
     *
     * @param i 那个位置的传感器
     * @return
     */

    public static Integer generalGatherValue(Integer i) {
        if (i == 1) {
            return HexadecimalExchangeUtil.generalPHValue();
        } else if (i == 3) {
            return HexadecimalExchangeUtil.generalWindSpeedValue();
        } else if (i == 5) {
            return HexadecimalExchangeUtil.generalSolidityTemperatureValue();
        } else if (i == 7) {
            return HexadecimalExchangeUtil.generalWindDirectionValue();
        } else if (i == 9) {
            return HexadecimalExchangeUtil.generalSoildMoistureValue();
        } else if (i == 11) {
            return HexadecimalExchangeUtil.generalAirTemperatureValue();
        } else if (i == 13) {
            return HexadecimalExchangeUtil.generalSolidSalinityValue();
        } else if (i == 15) {
            return HexadecimalExchangeUtil.generalAirMoistureValue();
        } else if (i == 17) {
            return HexadecimalExchangeUtil.generalAirPressureValue();
        } else if (i == 19) {
            return HexadecimalExchangeUtil.generalRainDownPerDayValue();
        } else if (i == 21) {
            return HexadecimalExchangeUtil.generalIlluminanceValue();
        } else if (i == 23) {
            return HexadecimalExchangeUtil.generalCarbonDioxideValue();
        }
        return 0;
    }


    /**
     * 获取采集的id
     * @param i
     * @param deviceIds
     * @return
     */
    public static Integer generalGatherId(int i, List<Device> deviceIds) {
        if (i == 0) {
            for (Device d : deviceIds) {
                if (d.getTypeid() == 32) {
                    return d.getId();
                }
            }
        } else if (i == 2) {
            for (Device d : deviceIds) {
                if (d.getTypeid() == 11) {
                    return d.getId();
                }
            }
        } else if (i == 4) {
            for (Device d : deviceIds) {
                if (d.getTypeid() == 23) {
                    return d.getId();
                }
            }
        } else if (i == 6) {
            for (Device d : deviceIds) {
                if (d.getTypeid() == 10) {
                    return d.getId();
                }
            }
        } else if (i == 8) {
            for (Device d : deviceIds) {
                if (d.getTypeid() == 24) {
                    return d.getId();
                }
            }
        } else if (i == 10) {
            for (Device d : deviceIds) {
                if (d.getTypeid() == 16) {
                    return d.getId();
                }
            }
        } else if (i == 12) {
            for (Device d : deviceIds) {
                if (d.getTypeid() == 25) {
                    return d.getId();
                }
            }
        } else if (i == 14) {
            for (Device d : deviceIds) {
                if (d.getTypeid() == 17) {
                    return d.getId();
                }
            }
        } else if (i == 16) {
            for (Device d : deviceIds) {
                if (d.getTypeid() == 8) {
                    return d.getId();
                }
            }
        } else if (i == 18) {
            for (Device d : deviceIds) {
                if (d.getTypeid() == 55) {
                    return d.getId();
                }
            }
        } else if (i == 20) {
            for (Device d : deviceIds) {
                if (d.getTypeid() == 60) {
                    return d.getId();
                }
            }
        } else if (i == 22) {
            for (Device d : deviceIds) {
                if (d.getTypeid() == 61) {
                    return d.getId();
                }
            }
        }
        return 0;
    }
}
